template <typename T> T sqr(T x) {return x*x;}
template <typename T> T max(T x, T y) {return x < y ? y : x;}
template <typename T, typename... Args> T max(T first, Args... args) {return max(first, max(args...));}
template <typename T> T min(T x, T y) {return x < y ? x : y;}
template <typename T, typename... Args> T min(T first, Args... args) {return min(first, min(args...));}

namespace utils {
    struct Circ {db x, y, r;};
    db dist(db &x1, db &y1, db &x2, db &y2) {
        return std::sqrt(sqr(x1 - x2) + sqr(y1 - y2));
    }
    db dist(Circ &c1, Circ &c2) { // Center distance
        return dist(c1.x, c1.y, c2.x, c2.y);
    }
    const char CIRC_CONTAIN     = 0b00000001; // 包含
    const char CIRC_INTERSECT   = 0b00000010; // 相交
    const char CIRC_EXT_TANGENT = 0b00000100; // 外切
    const char CIRC_DISTANCING  = 0b00001000; // 相离
    char circRela(Circ &c1, Circ &c2) {
        const db &r1 = c1.r, &r2 = c2.r;
        assert(r1 >= 0 && r2 >= 0);
        const db d = dist(c1, c2), sum = r1 + r2, dif = std::abs(r1 - r2);
        if (d <= dif) return CIRC_CONTAIN;
        else if (d < sum) return CIRC_INTERSECT;
        else if (d == sum) return CIRC_EXT_TANGENT;
        else return CIRC_DISTANCING;
    }
}

using utils::Circ;
using utils::dist;
// using utils::intrDist;
// using utils::protDist;
